﻿@inject SessionService SessionService
@{
    var isLogin = SessionService.IsLogin();
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>@ViewData["Title"] - Reader</title>
    <link href="~/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="~/css/site.css" asp-append-version="true"/>
    <style>
        body{
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }
        nav{
            flex-grow: 0;
        }
        footer{
            flex-grow: 0;
        }
        .content{
            flex-grow: 1;
        }
        
    </style>
</head>
<body>

<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <div class="container-fluid" style="width: 80vw; margin: 0 auto;">
        <div class="collapse navbar-collapse" id="navbarTogglerDemo01">
            <a class="navbar-brand" href="#">书籍在线阅读和分享平台</a>
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" asp-controller="Home" asp-action="Index">主页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" asp-controller="Book" asp-action="BookCategory">分类</a>
                </li>
                <li>
                    <form class="d-flex" asp-controller="Book" asp-action="BookSearch" method="get">
                        <input class="form-control me-2" type="search" placeholder="Search" name="keyword" aria-label="Search">
                        <button class="btn btn-outline-success" type="submit">Search</button>
                    </form>
                </li>
            </ul>
           
            <ul class="navbar-nav me-auto mb-2 mb-lg-0" style="display: flex; justify-content: flex-end; flex-grow: 1">
                @if (!isLogin)
                {
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" asp-action="Register" asp-controller="User">注册</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" asp-action="Login" asp-controller="User">登录</a>
                </li>
                }
                else
                {
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-expanded="false">
                            @SessionService.GetString("user.username")
                        </a>
                        <div class="dropdown-menu">
                            <a class="dropdown-item" asp-controller="User" asp-action="Info">我的主页</a>
                            <a class="dropdown-item" asp-controller="Book" asp-action="UploadBook">上传书籍</a>
                            <a class="dropdown-item" asp-controller="User" asp-action="MyUpload">分享记录</a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" asp-controller="Book" asp-action="BookShelf">我的书架</a>
                        </div>
                </li>
                }
            </ul>
        </div>
    </div>
</nav>

<div class="content" style="display: flex; flex-direction: column; margin-bottom: 20px;">
    @RenderBody()
</div>
<!-- Footer -->
<footer class="bg-dark text-light text-center py-3">
    <p>&copy; 2024 Book Website. All rights reserved.</p>
</footer>


<script src="~/lib/jquery-3.5.1.min.js"></script>
<script src="~/lib/bootstrap/js/bootstrap.bundle.js"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>